home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / FDF101.ARJ / ELIB.ZOO / askuser.c next >
C/C++ Source or Header  |  1992-04-30  |  538b  |  42 lines

  1. #include <stdio.h>
  2.  
  3. /*
  4.  *    ask_user()
  5.  *
  6.  *    Input:
  7.  *    Output:
  8.  *    Comments:
  9.  */
  10.  
  11. int ask_user(char *buf)
  12. {
  13.     int done = 0;
  14.     char ans[10];
  15.     int retval;
  16.  
  17.     while(!done){
  18.         fprintf(stderr, "%s", buf);
  19.         if (gets(ans) != NULL){
  20.             switch(*ans){
  21.                 case 'n':
  22.                 case 'N':
  23.                     retval = 0;
  24.                     done = 1;
  25.                     break;
  26.                 case 'y':
  27.                 case 'Y':
  28.                     retval = 1;
  29.                     done = 1;
  30.                     break;
  31.                 case 'q':
  32.                 case 'Q':
  33.                     exit(0);
  34.                 default:
  35.                     break;
  36.             }
  37.         } else
  38.             exit(-1);
  39.     }
  40.     return(retval);
  41. }
  42.